from langchain.vectorstores import Chroma
from langchain_community.embeddings import ModelScopeEmbeddings


texts = [
    '在这里',
    '你好啊',
    '你叫什么名字'
]
model_id = "damo/nlp_corom_sentence-embedding_english-base"
embeddings_model = ModelScopeEmbeddings(model_id=model_id)

#存储库
db = Chroma.from_texts(
    texts,embeddings_model,persist_directory='./chroma_test'
)

query = "谈话中和名字相关的有哪些？"
retriever =db.as_retriever(search_kwargs={'k':2})
docs = retriever.invoke(query)
for doc in docs:
    print(doc.page_content)